<?php echo $header; ?><?php echo $column_left; ?>
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-account" data-toggle="tooltip" title="<?php echo $button_save; ?>" class="btn btn-primary"><i class="fa fa-save"></i></button>
        <a href="<?php echo $cancel; ?>" data-toggle="tooltip" title="<?php echo $button_cancel; ?>" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
      <h1><?php echo $heading_title; ?></h1>
      <ul class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
        <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
        <?php } ?>
      </ul>
    </div>
  </div>
  <div class="container-fluid">
    <?php if ($error_warning) { ?>
    <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    <?php } ?>
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-pencil"></i> <?php echo $text_edit; ?></h3>
      </div>
      <div class="panel-body">
        <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-account" class="form-horizontal">
          <div class="form-group">
            <label class="col-sm-2 control-label" for="input-status"><?php echo $entry_status; ?></label>
            <div class="col-sm-10">
              <select name="navlist_status" id="input-status" class="form-control">
                <?php if ($navlist_status) { ?>
                <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                <option value="0"><?php echo $text_disabled; ?></option>
                <?php } else { ?>
                <option value="1"><?php echo $text_enabled; ?></option>
                <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                <?php } ?>
              </select>
            </div>
          </div>

          <table id="frall" class="table table-striped table-bordered table-hover">
            <thead>
              <tr>
                <td class="text-left"><?php echo $entry_title; ?></td>
                <td class="text-left"><?php echo $entry_link; ?></td>
                <td></td>
              </tr>
            </thead>
            <tbody>
         <?php $rowcount = 0; ?>
              <?php foreach ($setting as $onerow) { ?>
              <tr id="rowcount<?php echo $rowcount; ?>">
                <td class="text-right"><div class="input-group pull-left"><span class="input-group-addon"><img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /> </span>
                <input type="text" name="navlist_setting[<?php echo $rowcount; ?>][title]" value="<?php echo $onerow['title']; ?>" placeholder="<?php echo $entry_title; ?>" class="form-control" />
                 </div>
                  <?php if (isset($error_name)) { ?>
                  <div class="text-danger"><?php echo $error_name; ?></div>
                  <?php } ?>
                </td>
                <td class="text-left"><input type="text" name="navlist_setting[<?php echo $rowcount; ?>][link]" value="<?php echo $onerow['link']; ?>" placeholder="<?php echo $entry_link; ?>" class="form-control" /></td>
                <td class="text-right"><button type="button" onclick="$('#rowcount<?php echo $rowcount; ?>').remove();" data-toggle="tooltip" title="<?php echo $button_remove; ?>" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>
              </tr>
              <?php $rowcount++; ?>
              <?php } ?>
            </tbody>
            <tfoot>
              <tr>
                <td colspan="2"></td>
                <td class="text-right"><button type="button" onclick="addRow();" data-toggle="tooltip" title="<?php echo $button_add; ?>" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></td>
              </tr>
            </tfoot>
          </table>
        </form>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
var rowcount= <?php echo $rowcount;?>;
function addRow() {
  html  = '<tr id="rowcount' + rowcount+ '">';
  html += '  <td class="text-left"><div class="input-group pull-left"><span class="input-group-addon"><img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /></span><input type="text" name="navlist_setting[' + rowcount+ '][title]" value="" placeholder="<?php echo $entry_title; ?>" class="form-control" /></div></td>';
  html += '  <td class="text-left"><input type="text" name="navlist_setting[' + rowcount+ '][link]" value="" placeholder="<?php echo $entry_link; ?>" class="form-control" /></td>';
  html += '  <td class="text-right"><button type="button" onclick="$(\'#rowcount' + rowcount+ '\').remove();" data-toggle="tooltip" title="<?php echo $button_remove; ?>" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
  html += '</tr>';
  
  $('#frall tbody').append(html);
  rowcount++;
}
  function changeNum(){
    $("tbody tr").each(function(){
      var indexNum=$("tbody tr").index(this);
      var inputs=$(this).find("input");
      inputs.eq(0).attr("name","navlist_setting["+indexNum+"][title]");
      inputs.eq(1).attr("name","navlist_setting["+indexNum+"][link]");
      })
}
$('tbody').sortable().bind('sortupdate',function() {
  changeNum();
    });
</script></div>
<?php echo $footer; ?>